Fixed return values and removed unused variables
Fixed -Wall errors
Added compile option -Wall