Add mean() function and Fixes #2