Compile fixes
More compile fixes - missing includes
More compile fixes for missing/incorrect defines
Move valence-updating out of depsgraph queue code

It was too much work trying to integrate all of the necessary includes
into the code to achieve this. Perhaps later we'll ditch the separate
file and just merge the queue code in with one of the other parts of the
codebase instead?