Now passes -Wall -pedantic

Cleaned up the code even further, and tweaked it in response to -Wall -pedantic warnings.