Merging in changes from my fork

This PR has fixes from multiple issues. I'll be closing them as needed.