Fix coverity pf leak and cleaning the function up

CID fixed:
	1258915
	1258912
	1258911