Medium Access Control (MAC) main functions encompass contention for channel access, packet scheduling, error control, and data integrity. Channel contention is a collective function involving all stations in the network, while data integrity pertains to data flows of each individual station. We propose a design where contention related functions are separated from other data management functions. The hinge connecting contention and other data management functions is a flow control algorithm, aiming at guaranteeing stability of contention queues and load on the MAC channel. With reference to Carrier-Sense Multiple Access (CSMA), we define an analytical model of contention queues under non saturated traffic. An asymptotic analysis of the model for large number of stations yields a closed form of the optimal flow control rate. The insight gained from the model is used to design an adaptive flow control algorithm that guarantees throughput optimality for all values of the number of stations.