First commit of the code itself, requires a lot of cleanup to
make it more idiomatic