various improvements

- better flag detection
- more thread-safe
- removed traces of insecure bluetooth connections
- added semaphores (cancel and numeral)