Restructured to use interfaces better