Better path handeling

Thanks @orzFly