Adding state-based serial parsing and debug statements