Fix some incorrect math
Prevent negative values from being assigned to generators