various fixes (weighted mean, bugs, cosmetics)