fixes issue #142 messy validation

Seriously, all of this and most of the ugly bugs I have are because turns out something is null and nothing checks if it is, ever.