Refactoring and commenting vector functions.