Cleaning up code and added assert for emit_to_room