Tried to refactor, but had ClassCastExceptions. Reverting back to working state.