Yet another refactor. Don't expect it to be the last.