Fix some common bugs