Improve service path detection

#612