Some refactorings and a highly questionable bug fix.