Some more validations and cleanup.