Refactored some functions on Factor.