Fix for double diff, minor refactoring/fix