standardized parameter checking, cleanup