fixes and performance improvements