Legacy code

This first commit adds the legacy code written in a couple of nights to
itch my own scratch.