some minor cleanup & refactor