More main.rb refactoring