Removes unnecessary commands