Minor bug fix and small improvement