Added onOpen/onClose callbacks