The surface code, with a simple modification, exhibits ultrahigh error-correction thresholds when the noise is biased toward dephasing. Here, we identify features of the surface code responsible for these ultrahigh thresholds. We provide strong evidence that the threshold error rate of the surface code tracks the hashing bound exactly for all biases and show how to exploit these features to achieve significant improvement in the logical failure rate. First, we consider the infinite bias limit, meaning pure dephasing. We prove that the error threshold of the modified surface code for pure dephasing noise is 50%, i.e., that all qubits are fully dephased, and this threshold can be achieved by a polynomial time-decoding algorithm. We demonstrate that the subthreshold behavior of the code depends critically on the precise shape and boundary conditions of the code. That is, for rectangular surface codes with standard rough or smooth open boundaries, it is controlled by the parameter g=gcd(j,k), where j and k are dimensions of the surface code lattice. We demonstrate a significant improvement in the logical failure rate with pure dephasing for coprime codes that have g=1 and closely related rotated codes, which have a modified boundary. The effect is dramatic: The same logical failure rate achievable with a square surface code and n physical qubits can be obtained with a coprime or rotated surface code using only O(n) physical qubits. Finally, we use approximate maximum-likelihood decoding to demonstrate that this improvement persists for a general Pauli noise biased toward dephasing. In particular, comparing with a square surface code, we observe a significant improvement in the logical failure rate against biased noise using a rotated surface code with approximately half the number of physical qubits.