Added beforeBuild and afterBuild hooks