Fix some NPE

Thanks Koush
Fix missing notification received before register response

Thanks Nicolas Christe
Fix premature return from for loop

Thanks Kai Kreuzer