Cleanup - moved major parts from main() into own functions