clean up javascript and remove null reference errors (scaling still not working)