Moved code around for bugtesting.