Fixed NPE when discovering (caused by race condition)