Some refactoring due to library changes.