small fixes and refactors