rename delegate to manager for consistency
allow errors to be returned and clean up unused variables
avoid JS syntax error when passing back JSON