Removed troubleshooting code in energy function.