[#1] more refactoring, get the main class out