Some debug logs and minor fixs.