cleanup and validation