MDL-32941 Reorganise functions a bit