Refactored / fixed js.