Cleanup

This now includes all my patches and is a complete cleanup of some parts of the code.

Please note that I'm breaking backwards compatibility, hence the version upgrade.