Fixed bugs in install script and lib scripts