Cleaned up use statements and fixed from comments
Added the ability to close database connections for long running tasks, and brought the comments up to spec