Cleaned up cleanup code