Now uses logging for output
More debug output
Fixes #3 now allows storage dir to be specified
and closes file handles