adding logging and GPIO cleanup