Fix a few bugs in vector.h and vector.templates.h