Bug fixes

Fixed a few bugs related to validation.