Initial commit of quasi-working code