Fixed the code to use strict, did some optimizing.