code cleanup, close database