Fixed header define guards, moved some control code.