Main loop now works
Fix'd off by one errors in the accessors