New sphere code blatantly stolen from internet forum