Fix #29, memory leak caused by unreleased refs.