Bug fixes and improved documentation