move printout code into stand-alone method; add observations in comments
dispose datastore on error; cleanup source code