minor changes
heavy refactoring; broken