Indexed variants of scanning and aggregating

Based on and resolves #1254.