Huge refactoring for wikibrain!