Making document a param of [[Register]] and [[Unregister]]. Fixes #390.