typeOf is now automatically assigned. Fixed logic bugs.