Fixed indexing errors, something odd is happening with arithmetic results