First commit, very rough draft, thanks to rando on stackoverflow