Lots of duplicate code, refactor (later).