even more performance improvements + some code cleanup