Cleanup unused vars revised
This removes most of the unused vars from the core. All that's left now are some in the expr code-- we should try to get those removed and merged upstream since we're basically copying directly from the expr changes atm.
Compatibility mode (which seems to be unused) was added.
Also some headers were missing in some places, causing some functions to be declared on the spot.
A few issues remain-- they are the ones that looked more involved and had potential to cause breakage.
Once this passes CI it can be merged.