#98 fixed, minor other optimizations