use size_t consistently, misc cleanup