Minimize changes to original qm.js