Added more catches for unexpected behavior

Also added equality operators for PolyMod.