Try to pass a group when removing a contact. No idea what will happen if a contact is in multiple groups, for now I'm not supporting it.
Also cleaning up query code to avoid calling NULL.