Should've forked this from sjvasquez. I'm just adding comments to his work to help myself understand what he did.