torch and some fixes