Cleanup unused variable.
Remove unnecessary assignment.
Use malloc wrapper.
Use correct integer type in format string.
Merge pull request #274 from rrebello/ag_fixes

Misc fixes