Initial commit of source code.

Still unfinished, needs cleaning up.