Fix bug. Improve diagnostic capabilities.