Updated version

Bugfixes and optimization of code.