Check thrown exception types properly. Return by reference from 'get_key' so that the keys aren't copied. [SVN r3115]