Changed parts of HAL to C++, fixed module loading bugs