Simplify code and fix case where distro is unset