Update TODOs
Major code reorganization

Move functions into logical order, not false dependency order
Put all globals at top
Put UI event binds at bottom