Bug fixes and optimization
Bug fixes