changed the code to support the new hardware setup and modified some parts to be more modular