Fixed a small bug with the Prepare function on the wrong scope.