Removes all syntax errors, and bad references