Fix before and after hooks