Some important bugfixes