Changed the architecture to be more flexible.