Optimizations

Should see much better performance now