Adjusted some timeouts and fixed possible memory leak.