minor refactors and fixes