Code cleanup and header fixes.