Performance optimization, bugfixes and refactoring
Update tests
Added benchmarks