Fixed a bug that took all day to find!