Simplified vector assignments and changed most functions from pass by value to pass by reference (const reference where appropriate)