Work towards a stable release.
This fixes various bugs + sets the version to 4.0.