Adds an "agent" parameter to the constructor.
Extra definedness check.
Removes useless require.
Properly handle even class names with embedded quotation marks.