Removed unneccessary code. Fixed potential bug regarding typeids