flymaple c++ code originally developed by Yi Xie