Full rewriting vector.d. Logic and sense added