Various code/doc fixes/improvements and test additions