Store finished element into local storage.

Also fix bugs in data storage functions, now returns the correct result.