Device 

Added stack-based state machine for devices and heartbeating between device and modules.