Allow override port value with env.port
Initialize variables to zero and use sum of all nodes instead of last one