cleanup/reduce the ammount of code (-111 lines)

hi there,

In a fit of boredom I refactored your code, reduced the line count somewhat, yours if you want it :).