Some improvements and small bugfixes