Crossings and nestings of matchings and partitions