Fix potential bugs in interval decoding