Minor bug fix and added debugging info