Added "use strict" and fixed some hidden bugs.