Fixed wrong reference and added debug info to log