backend/tdm: Split commit function into small functions