Changed code to be portable to other environments.