Clean up and update code