fix identation and prevent a few tiny memleaks that could occur if R_NEW0 fails