Fix for issue #38 and some error logging cleanup
Added use of logging module