Code simplification and conversion to PyNDN