removes unnecessary vars and code