Remove log calls, make sure path is converted to string, cache length, clean up loop