* Cleanup for r37375. Split duplicated code into function and really fix it