Added temperature stuff and cleaned out code