minor style improvements
Refactored to implement module pattern. Also added "use strict" to ensure ES5 compliance