Bunch of bug fixes.