Better handling of std values and fix bug in pull request # 48 - resubmission

Hope its better now