Fix the reference problem whether as standalone program or as external module