remove pointless use of stats
fix ID generation. patch by Peter S.