Added beforeOpen/afterOpen callbacks; provided example usage in
documentation.