Fixes divide by zero error if all values are the same
Moved padding into define