Cleaned up EM and wrote UGM test cases