Extract a new start function to more closely match the Ruby implementation
Simplify the main function