lots of changes, mostly removal of useless code