Add vector length function to ex5 and tidy up