Added open and refactored a little.