Minor tidy up of pattern matching

Also added a comment and link re exception handling in agents.