Move _extension.c to extension/_factory.c and add layout_struct function