refactor & prepare to add panel support