Reorganize metaprogram frame related code