Also fix some blatant build errors. I must be going mad - I swear I've fixed that typedef thing like twice already.