Made some speed improvements to the input