Tidy up a little, fix array accesses.