Adds param checking, quick return and error codes.