added functions to remove duplicate commands

Also moved modules to inside chroot as well as out of it.