Add include files to get prototype declarations, and fix bugs found.