major improvements and bugfixes