Bugfix median calculation