Tidy up whitespace, error responses and routing