Add before and after hooks

References: #48