Fixed bug with $tables getting appended to and added sanity check to 'rm -rf' system call