Further changes and bug fixes - sorry for the non-descriptive comments.