Cleaned up code from last patch