Fixes for average, where, select and window