Learning the basics of quantum theory, one thing I can't quite grasp is how quanta, especially the e=hf equation, works within the law of the conservation of energy. I imagine the heat death of the universe for example, and taken to the extreme end all masses have been converted to energy...