Varius improvements and bugfixes