some refactoring. Added qthab.