Address Dojo memory leak

Also updates code style for the affected file only.

Fixes #1086
Closes #1087