Refactor of previous monolithic code complete

The previously working code (the point where I was about to write the attach HDD code) has been rewritten.

There is some other refactoring I'd like to do, but I want to test against the actual API first.

Signed-off-by: Ippoippo <ippoippo-software@ippoippo-eco.com>