debug & misc refactoring