Improved chart performance and refactored some variables