Add event system and fix bugs with packet ids 4 and 27.