Major efficiency updates to .js file.