Fix integer primitive unification bugs and expand to encompass bigints

This includes #307 and parts of #308.