Made TODOs clearer and tidied some code.