Refactoring HW

there are still a lot of things to do