Cleaned up code a bit; got rid of the size_t hacks