minor fixes & refactoring