The repository is quite a mess and needs a major reorganization. That and some of this code really needs to be refactored.