Implemented IDisposable for Pattern classes.