From @neilt6: Modified to allow share mode control