Fix bugs in script, remove -p option