parentNode function fixed to avoid segmentation fault
various changes