Implemented a type checking ability, and refactored