rm redundant code
Fixed function pointer type (gcc warning)
Fixed printf formats gcc warning)
Removed debug print outs