Half-way through optimising code

Tim's half-cooked code