Optimization of Dead Time in SPAD-based Photon-Counting Communication System with Afterpulsing