major refactor (cont.) (partial)