Refactor applicaiton.rb

`application.rb` is a pretty big file, and it's difficult to follow. Hopefully these changes help.
I wrote this up a while back
, but never opened a pull request. Let me know what you think!