Fixed a bug and discovered another bug