Fixed error in coordinate conversions, pointed out by @sarbian.