Modular branch, now with comments and some minor simplifications