Modified BB84 quantum key distribution protocol robust to source imperfections