Added basic validity checking.