Changed types of some variables from int64 back to int.
Also corrected some indexes to be size_t.