Code cleanup (and addressed a few TODO comments I forgot to handle in the previous commit).