Refactor beforeRender() to support async op #282

Just for review