Changed the dispose routine slightly to remove warnings