Make some variables local, add an util