More cleanups: moved a function declaration to the correct module, removed old/incorrect comments, marked more things with TODO where appropriate, refactored copy-pasted function, de-duplicated code.
More cleanups: moved a function declaration to the correct module, removed old/incorrect comments, marked more things with TODO where appropriate, refactored copy-pasted function, de-duplicated code.