Rename type -> autocode_type and add small bugfixes