Initial commit. Code appears working but not thoroughly tested.