lots of refactoring for new qadapter