Initial commit with 90% working code, needs major tidy up