Refactor the verilog a bit