Change average key to median. Fixes #8