Initial commit. Still some work to do cleaning things up, adding comments etc.