stat db migration, fixes and moment count