Refactor titlebar