Fixed bugs for linux compatibility