Implement avgby. Fixes #30