This may need some cleaning up, but this is the first iteration to appease the compiler.
And more flushed out but incomplete