Speed up qsim and add more precision.