Fixes some bugs and some minor connected issues.