Moved the title bar algorithms in a separate class.