minor refactoring
few fixes