More qa and refactoring