fixed #40, also corrects the redirect when the title of a document is changed
Refactored edit handler.
Merge pull request #45 from l--f/fix#40

fixed #40, also corrects the redirect for changing title of a document