initial checkin

some old code i dug up, added some features but still needs some big
refactoring