Rewrite lib.sh