Refactor, implemented close.