Added "use strict" and refactored.