Added beforeRender and afterRender callbacks