cleaned up, even more robust, added logging, feature inactive by default