add support for root paths in images + heavy refactor