Reorganize files to improve portability

* Added checks on environment (available commands)
* Reorganized Python code