Add close() method, changed exception throwing