Fixed more bugs that cropped up after re-write