Bug fixes and performance improvements