Back port of #746 to groovy

Back port of #746