Reorganizing code a bit