Moving code around and some cleaning of unused stuff.