Added beforeHook option and task/target options merging