Drastic rewrite to enable easier adding of sensor functionality

Big rewrite to make it easier to add more capabilities in the future.