refractor of enginebuilder with two inner classes