Fixes crash, cleaned up for 64 bit

* Added type-safety for 64 bit
* Fixes the divide by zero error, if all values are the same
* Moved padding into `define`