various improvements to performance and whitespacing
some rough tests, todo: cleanup