Moved a bunch of code