Made some small speed ups and improved string handling