fixing lots of things, including issues identified by Dave Myer