added some more strong type checking stuff
many more type checking fixes