fixes issues with 32bit intsets

some code cleanup and small fixes.