fixing potential NullPointerException if performing discovery on a
non-existing cloud number
few more cosmetic changes