Fixes all syntax errors and missing references