Refactored window cleaning for better performance and lisibility