Bug fixes and tests
Bug fixes and tests