Syntax errors, additional middleware and clean up