Remove trailing whitespace
Consolidate quit check
Remove extra else blocks that are not needed
Don't need to check for keyboard interupt really
Refactor the code a little in order to reduce the ammount of duplicate code