clash of clans - optimized js, added saving of calculations