added many performance improvements