Refacture and cleanup