fix scope.apply after setting scope.
remove unused code.