Removing unused vars and references