Some refactoring of stuff.