Small fixes and performance improvements