Potentially fix not properly unloading

Also read from a debug setting for enabling debug mode and some minor
cleanups.
Release 1.0.2