Rehaul of the code