Fixed for Go 1.2 and cleaned up a bit.