lots of refining and cleaning up after removal of sml