Remove redundant memory allocation, and some code cleanup.

Signed-off-by: Kumar Amit Mehta <gmate.amit@gmail.com>