Reorganize modules a bit to simplify code