Some code fixes