Refactoring to use #current_object and #current_document instead of @obj...

...ect and @document instance variables.

Fixes #322.
Fixes #323.