Code cleanup, style consistency, prevents global leaks