Fix up a few bugs