some fixes to make more portable