added beforeInit and afterInit options