Cleaned up code to compile with '-Wall -ansi'