fixes and refactoring - XCB app