Added type checks before all casts in the standard library
Fixed missing standard library type checks before casting