Probably the least risky way is flashing original firmware and then modifying individual files step by step.