Moving code around, cleaning up