Code unweaving and generation fixes