Modified mode control logic to prevent transition to takeoff mode while in flight. Corrected the sign of the altitude command.