Sped up cube normalize function. Also went nasa paranoid on a
potentially infinite loop.