Checked-out from 18.. branch in order to change algorithm