Refactor things into lib/.