Cleanup: standarize variable names, move vars to top of file, get rid of unused functions..