Cleaned some old code and hopefully fixed the bug that was preventing a painful switch to phase 2