Some minor code fixes