some more cleanups and less frequent crashes