Moved some things around for efficiency.