First working c++ version with enum support