added safeClose() to common class
removed more old code