Fix some code, and prevent double defined