Some refactorings to remove hard code.