Added 'use strict' and cleaned up the code per JSLint's recommandations