First commit.
Ripped from existing solution, still needs pruning for general use