Fix some build errors, and build with flat_namespace