made functions global instead of static.  Added docstrings.  Updated logic when retrieving/adding records.
a lot of cleanup