Updated to better control Power On/Off events, adding timer functionality.