Added validity checking for various types