various small code fixes