Cleaned up obsolete and test code
Fixed selection highlight lost after editing