Added dumpstack function for debug purpos.
Fix stack index issue and free strings at proper place