Fixed up bugs all over the place