Added benefitial changes from lite version of selfspy