last revision before complete rewrite

It's working, but Web app has HUGE memory leaks everywhere. Complete
rewrite required.