Cleaned up disconnect code