Added rudimentary error checking to main() and cleaned up some unused functions. Fixed an unnecessary explicit definition in main().