rewrote handleMode to use our more modern helpers
cleaner config handling in main.js