Port of vec.php.  Debugging required.