Fix up bugs