more performance improvements and bug fixes