Added history sub and fixed sub variable forwarding