Updated code to fix timing errors due to long/int.

Also refactored some parts and added support for pushbuttons to
change the set temperature.