Small fixes and performance improvements 2