resolved a bunch of minor errors based on gcc's -Wall compile option