more cleanup and added terminal inputs