Updated code with comments on the TODOs.