Fix various stability bugs.