improved performance, added bugfixes and small refactorings
more performance improvements, bugfixes and small refactorings