Small improvements to the modifications code, with some tests