some minor refactors and cleanup