WIP refactor
WIP, 2nd one...basic functionality restored
WIP, remove comments, formatting