Fixed various data type bugs, and cleaned up signed vs. unsigned and int vs. size_t issues