Close connection when done and comment unused functions accordingly.