Smaller main function

Application initialization is now done in a run() function rather than main(). See this blog post for the rationale behind the change.