Adding diagnostic logging