Some bugfixes