Safety checks + bugfix