I may have fixed it. 

I think I made the keys for degrees greater than one as strings instead of ints. I feel a little stupid.