Changed the Mode function in average module to handle bi-modal and multi-modal modes.