Cleanup command for IPM domain

http://manage.dimagi.com/default.asp?147063
you could save yourself some DB lookups if you keep a dict of case_id's --> location_ids in memory after you've done the lookup once.