lots of basic improvements and bugfixes