fixes to increase portability of program across platforms; minor fixes elsewhere