fixing vector related bugs, adding a macro to do code test
Merge bugfixes with latest commit