fixing some issues with promise leaking