Complete re-write using localstorage to cut down on ajax calls