Add STB csr fields
Solve some memory problems