initial commit

untested, untried, whateverified code, ripped straight from DaringFireball's bowels and hacked unceremoniously