fixed a crash that would occor on 64-bit devives caused by erroneous assumptions of type-sizes. And Fixed some static-analyizer warnings about losing precision due to erroneous assumptions about type sizes.