Move code under namespace + some fixes