minor changes to improve portability