clanup of mainhandle