The Shtarkov or "Normalized Maximum Likelihood (NML)" code plays a fundamental role in universal coding and in Rissanen's minimum description length (MDL) principle for model selection and prediction. The NML code achieves the minimax regret relative to the given statistical model. Unfortunately, for many important models - including models as simple as the normal family - the NML code is undefined, and the approach has to be modified. We present a new generalization of NML which provides a generic solution to this problem: the 'luckiness NML' (related to the 'luckiness principle' in learning theory) and its special case, the 'conditional NML'. Luckiness NML can also be applied to non-parametric model classes such as Gaussian processes. Conditional NML is related to objective Bayes approaches with improper multidimensional Jeffreys' prior, and sheds new light on the old question whether it makes sense to use such a prior.