Also, use size_t instead of int to avoid compiler warnings and slight performance loss.