Fixed two bugs (thanks to Bryce Beattie)