Fixes and performance improvements