enhance support for Python and Python packages

builds on top of @JensTimmerman's PR #322, applies minor style fixes