Refactured message serilization code, simulator working