Changed unsigned variables to signed, added size_t variables