Improved performance and fixed bugs