Added IDisposable class to deal with resources.