Moved some code around to utilize packages.