JS fixed; minor design flaws removed