Bunch of random bug fixes.