WIP: Some modifications to improve performance, largely unsuccessful though