qsim fixes.
Fix off-by-one.