fixed major bug fix with rm command and minor code cleanup