Changed data type for some variables from unsigned long to size_t.