In this paper we formally analyze the interleaver and code design for QAM-based BICM transmissions using the binary reflected Gray code. We develop analytical bounds on the bit error rate and we use them to predict the performance of BICM when unequal error protection (UEP) is introduced by the constellation labeling. Based on these bounds the optimum design of interleaver and code is found, and numerical results for representative configurations are presented. When the new design is used, the improvements may reach 2 dB, and they are obtained without any increase on the transceiver's complexity. We also introduce the concept of generalized optimum distance spectrum convolutional codes, which are the optimum codes for QAM-based BICM transmissions.