Add extra logging

Code by AW.