Improve handling of sigma types in the standard library.

Pull request for bugs 3043 and 3044.

I haven't actually tested this yet (I'm testing it now, and will comment when I've succeeded in testing it).