rich0s modifications to ferringb's scripts