fix crash from Conn use after free and double-free

fixes #159
don't over-specify the format of stats id field

Other stylistic changes.