Refactored logic to allow calculating the percentage of items in pie charts. Fixed bug causing flickering popup. Style improvements.