Many small bugfixes, tweaks