Merging unstable version

This is reasonably good enough to be production code.