various bugfixes, improvements