Fix leaking timers and other memory issues

Fix leaking timers and other memory issues