Lsm cleanup

@agorrod This isn't ready to merge yet as I'm still making changes, but I'm creating this so that you can easily look at the code so far.