Fixed some 64bit warnings by using size_t and fixing compare functions.