Some refactoring

I've been toying around with your repo and refactored some code. Here is a pull request, if you care for the modifications I've made. Anyway, interesting litle repo you have there :)