validation and cleanups