Small code correctness changes