Some validation
Merge branch 'master' into toan
Fixed if stmt, I think