fix option validation and cleanup