cleanup javascript, fixes #410