changed intptr_t to size_t + minor cleanup