Fix multiple issues buildenv setup

Changes in this pull-request also fix #1