Various performance related fixes