Metrics, logging, performance

Issues with metrics
Logging for debug
Performance improvements