Bug fixes and validation improvements