add namespace, fix a bit of code in mega.cpp