Pauls magic 4000x refactor