L2P: fix off-by-one errors