More code cleanup and converstion to ANSI C.