Fixed functions not escaping while loops properly.