A batch of new features

This PR fixes several bugs and adds a couple of new features.

Unfortunately, it breaks some of the interfaces, hence the major version bump.