Fixed some variable. cleaned up unused stuff