Update documentation and fix more bugs

And fixes #394