Unsure about this. @tjfontaine, can you verify correctness?