refactored app.rb

Fixes #31.

@jnicklas Hey, I have tried to refactor this a bit. If you like what I have done, I can refactor the code further. Just want to check with you if I am going in the right direction.