Finished Javascript overhaul (undebugged)