Fixed segfault caused by commit c07d2b76bbfce078e9
Fixed memory leak due ref_count will never reduce to zero
Merge pull request #119 from bixuehujin/bugfix

Fixed segment fault caused by my previous commit & minor memory leak