restructure main, ready for demo