Timing fixed, threading seems to work, wakelock added, filewrite still missing.