compilation fixes; refactoring; removed platform-depended code