Fix memleak and format apply_room_update