Minor updates; included <algorithm> to compile on linux