A few bugfixes