fixes to ported vb code