Removed redundant code.

Fixed the dispose pattern.