Fix reference refactoring, fix verses array out of bounds bug