Updated `classOf` to check for undefined first (for older versions of ie).