minor code improvements as suggested by SP