Fixed Mem leak, Minor other changes