Some checks and bugfixes