Fix table writing