Cherry-picking Hironao's excellent sky transform stuff (#7)