Seemed to have fixed resource leak