Fixed bug with cmd staying around, removed unused code