Fixed to compile with new packet types. Lots of TODOs.