minor refactors, optimizations