Wrote first-pass at a substitute function, and reworked the data storage.