Move mw loop() code into separate methods.  Cleanup related code.

If a given feature or mode is off the next task is not processed in the
current loop but will be processed during the next loop iteration for
simplification, this allowed the cleanup of return values in other code.