refactoring. still need to refactor static injection, fix formatting as
per Christian's comments and deal with other comments related to
refactoring.