Vector refactoring

Now vector is used everywhere, except when using library functions,
obviously.