Add some performance improvements for assignment, and some tests