Exception on invalid path and perfomance improvments