Merge and code review

Hi rmrfchick,

Mercora ask me to update your branch with the changes we made in master. Also, he ask me to do a little code review so I did it, my comments are marked with a TODO, but of course, you don't need to do it :-), they are just a couple of suggestions.

You can found me in the IRC channel if you have comments.

HIH