clean up ch.6 hierarchy code