To clean up code all integer conversions are now done by a helper function with proper checks in place.