General Code improvements to prevent lags and crashes.