bug fixes and integration with the hw_loop. Works in dry simulation