Added pre-serialize event handler to prune empty links or resources.