First draft of wig wag code
Tidied up some code layout
Fixed bug re when to wig-wag.