Various fixes and variable renames.