first draft of normalization
huuuuge changes that should go to different commits...
fixes and removed some debug output