fix a few bugs that cause big explosions