Linux script bugfixing stage 1