Clean up polling logic; use pattern matching for readability