Various Fixes

Merged from pull requests against @jhusain's repo.