fixing mysterious bugs