Lots of crap but this proves it works. Now to finish and refactor!