Split main loop into two functions: one per 'state' (reading envelope versus ready body)