cleanup and basic validation