Moved code around for easier syncing