Change a lot of vars to local, and fix prompt