updated MDB Port, considered porting to C++