Added stats tracking. Fixed some issues.