Added some calculations to Mirai's code.