Several improvements

Here is several improvements I've made.
I can't make separate pull request because they're all related.
I'll try to catch you on irc to talk about it (I also have a few questions).

**Edit:** Turn out to be pretty big changes...