check out foam. it has general RK4 implementation not tied to any _balls or stage references. that might be easier to port.