Various bugfixing, some work on stats