Input problem fixed and more cleanup