Fixed some code being in the wrong scope.