REL-1368: Replaced asInstanceOf with match statement.