many refactorings attempting to make the driver a bit more efficient