Fixed unstablity due to bad indexing.