sources refactor almost done