Lot of cleaning up code