Fix an issue where we were trying to serialize an anonymous class