all done, with comments and special cases