Moved energy evaluation code into its own file to improve readability.