Changed runtime system to be iterative instead of recursive.