Changed to actual JavaScript implementation (WIP).