TODO: Make magic box static & check for bugs.