Added logging, and reformatted some code to comply with PEP8.
Added AlarmControl to handle alarm-related logic.