Bug fixes plus 21_2

Fixes to bugs in previous version of avg.m and new solution 21_2 aded