refactored to have saner data model, and beginning of a plugin system