Made the type check case insensitive, and fixed a missing self.validTypes reference that caused an error on catching an invalid type.