remove unnecessary code and unref handler