Cleanup, removed warnings, added close() call