Slight refactoring, still need to extract sinatra routes and unconflate state in tests.