Made the bug fixes Francesca suggested