Fix nested namespace error and some warnings