Various bugfixes and barostat checking fix.

Note: this request is to pull my patches into your examples branch, essentially patching your existing pull request.