move aps state machine method bodies into cpp