fix answer editing

There were a few related problems, and a lot of duplicate js code. Fixes #122