Remove dup. code and impl. missing close().