add margins control to rtgeom, rearrange more code