Fixed adding sensors. Also some cleanup.