Lots of changes to fix overall performance