Added extra logging in debug mode