Handle typedef and reorganize code resolution