Fixes variable global leak.
Updates TODO list to extract and refactor functions.