The emergence of networks of many devices in the context of cyber-physical systems motivates novel solutions for communication over random access channels. Currently deployed random access protocols attempt to avoid collisions, and target the performance of a scheduled multiple access system (a strategy known to be only suboptimal from the information-theoretic perspective). In contrast, in this paper, we allow collisions among the transmissions of different users. We consider code design for random access channels with erasures in which the number of users in each frame is unknown at the transmitters but known at the receiver, and we present a two-layer coding architecture for joint contention resolution and erasure correction. Considering machine-type communications, the two-layer scheme is designed for short classic linear block codes. To invoke an asymptotic analysis with density evolution, we approximate the average error correcting capability of families of short codes, while assuming the number of active transmitters is large. This enables optimized code design for maximized throughput with constrained outage. The results show that as the number of transmitters increases, the performance gap between the classic and modern codes rapidly declines.