Improve folder monitor and move some logic from file monitor there
Previously file monitor and folder monitor was operating on the same
event in 2 threads. Now the logic is moved into the folder monitor.
Also folder-monitor handler is improved.
Closes: #267
Closes: #1080