Code factoring