Some correctness fixes for #8