Revert "Revert "Readd magic""

This reverts commit 93c58dc4db03886e8d47d13e636e083b8f0497d5.