fix a potential build issue + minor code changes