#50 extremum calculations fixed; minor bugs