cleaned up mode filter code. Return instead of setting result and then
returning.
Merge remote-tracking branch 'origin/develop' into develop