minor fixes and refactors