refactor and cleanup for maintainability
more collecting and refactoring
another step in finetuning