Fixes for while loops inside of functions. While loops count to 1 higher than they should however.