Reinstate code from CDVShared.h