more clean-up

more functionality moved from main.js to functions.js