Fixed an error that was unbalancing trees in a weird way.  I had left in mod 3 where it should have been changed to mod 2.  I also fixed some analysis warnings about casting