bugs with NPE fixed (at least, one of them)