Cleaned up and optimized vector.cpp