rewrite the whole hardware handling thing

still a bit bad, but by far not as bad as before