Various bug fix