Add some optimizations to function integer:factor