Optimizations

Hope this is much faster! Still needs a big cleanup!