Improved molecule.py and nifty.py