Bugs fixed in average calculation module and in retilting module