Added beforeRefresh and afterRefresh callbacks.