Small tweaks to make it build correctly

Switched around #include orders, mainly. And some other improvements.