minor fixes and performance improvements