commit 3

Should work. Not thoroughly tested, but seems complete.