Added --energy-rank option;
Splitted some functions