fixes to some stats errors
added db indexs