Add TODO comments and polish some code