Fixes some bugs and corrects usage of .type