Major merge

Hey Matt,
I've decided to redo the work, sending the commits in an ordered way. I hope you'll find the time to review them soon.
I'm testing the gadget right before sending each commit, so you can skip that part if you want to.