huge architecture-rewrite