Fixed a few bugs in double to int casting in energy grid index calculations