fix some warnings
fix a memory leak
consistent argument-passing style (space after comma between arguments)