added magnet threshold option, cleaning code, trying to fix issue with phone not waking after extended sleep