Adapting changes from 3.x