Fix creation of top and bottom masks and top masks.
Fix bottom and top mask creation in base.
Temporary fix to nax_int value to avoid underflow.