IBT: lots of fixes to refactor