added parameter that allows to switch off insertion of
boundary segments. Default version behaves as before.