Cleaned up validation and condition code