Bug fixes and documentation