some small edits and refactoring ideas marked with bk tbd