Split client logic into state stack