Improved generation and validation