Hooks OpenBag and CloseBag.

Should fix #217.