Fixes some critical errors