Tidier implementation of previous commit. Should fix for subclasses of individual tools too